I would like to develop web applications with flask which are also running on my local system without using flask.
I am searching for something like:
<link href="{{ url_for('static', filename='bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet" type=text/css> if link above is not working, use: <link href="../static/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
I also tried the code below and various other lines. However, it didn't work. <link href="{{ url_for('static', filename='css/bootstrap/dist/css/bootstrap.min.css') }}" onerror="this.onerror=null;this.href='../static/bootstrap/dist/css/bootstrap.min.css';"rel="stylesheet">
I would like to use this for 20 different css and around 30 diffrent js sources so I am searching for a simple solution which is easy to maintain. Do you have an idea? Can you help?
Thanks, Denis
You must be logged in to post. Please login or register an account.
It should work locally, not too certain why it's not.
If you right click the missing image, what is the path showing up as?
-Harrison 7 years ago
You must be logged in to post. Please login or register an account.
I use <link href="../static/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> now instead of <link href="{{ url_for('static', filename='bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet" type=text/css>
Now it's working both locally and on a flask server. url_for is only working with Flask right? What is the advantage of using url_for instead of something like "../static/your_url"?
I also don't get why this is not working: <link href="{{ url_for('static', filename='css/bootstrap/dist/css/bootstrap.min.css') }}" onerror="this.onerror=null;this.href='../static/bootstrap/dist/css/bootstrap.min.css';"rel="stylesheet">
Thanks for your reply Harrison
-Funi 7 years ago
Last edited 7 years ago
You must be logged in to post. Please login or register an account.
url_for is for flask, yes, but what you can do is use url_for, load the page in a browser, and see what the path is being converted to. It might just not work locally for some reason.
-Harrison 7 years ago
You must be logged in to post. Please login or register an account.